package com.xgx.distqcp.Interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.render.Render;
import com.jfinal.token.TokenManager;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class CheckTokenInterceptor  implements Interceptor  {
    public void intercept(Invocation inv)  {
        String token=inv.getController().getRequest().getHeader("Authorization");

        System.out.println(token);


        if (token!=null && token.equals("1"))
        {
            inv.invoke();
        }
        else {
                String data = "不见了远处的青山";
                inv.getController().renderText(data);
        }


    }
}
